<template>

  <div class="vxe-container">
    <div>
      <br>

      <el-dialog
        v-el-drag-dialog
        :visible.sync="fmodelModal"
        :close-on-click-modal="false"
        title="加账项目清单"
        class="config-dialog"
        @close="closeDialog">
        <el-input v-model="fmodelKeyword" clearable placeholder="搜索" style="width: 160px;" @keyup.native.enter="searchFmodel" @change="searchFmodel" />
        <el-select v-model="fbrand" clearable placeholder="请选择品牌" @change="selectBrand">
          <el-option
            v-for="item in fbrandList"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <el-select v-model="fdanweibumen" clearable placeholder="请选择部门" @change="selectBrand">
          <el-option
            v-for="item in fdanweibumenList"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <el-button type="primary" @click="searchFmodel">搜索</el-button>
        <el-button type="primary" @click="fmodelConfirm">确认</el-button>
        <el-button type="primary" @click="importData">导入</el-button>
        <el-table
          v-loading="fmodelLoading"
          ref="fmdTable"
          :data="fmodelListData"
          style="margin-top: 10px;"
          max-height="600"
          element-loading-text="正在加载"
          border
          highlight-current-row
          @selection-change="handleSelectionChange">
          <el-table-column
            type="selection"
            width="55"/>
          <el-table-column
            align="center"
            prop="fcode"
            width="100"
            label="代码"/>
          <el-table-column
            align="center"
            prop="fname"
            width="200"
            label="名称"/>
          <el-table-column
            align="center"
            prop="fzjqty"
            width="120"
            label="装机数"/>
          <el-table-column
            align="center"
            prop="ffaxamount"
            width="200"
            label="含税金额"/>
          <el-table-column
            align="center"
            prop="fqtyremark"
            width="160"
            label="数量注释"/>
          <el-table-column
            align="center"
            prop="fdanweibumen"
            width="160"
            label="部门"/>
          <el-table-column
            align="center"
            prop="fremark"
            label="备注"/>
        </el-table>
      </el-dialog>

      <el-dialog
        v-el-drag-dialog
        :title="importGrid.title"
        :visible.sync="importGrid.fmodal"
        :close-on-click-modal="false"
        :show-close="true"
        class="import-set-modal"
        width="78%">
        <div class="search-grid">
          <!-- <vxe-button status="success" icon="vxe-icon-add" content="新增" @click="importGridAdd"/> -->
          <vxe-button status="success" icon="vxe-icon-save" content="保存" @click="importGridSave"/>
          <vxe-button class="import-excel" status="primary" content="导入Excel" @click="toImport" />
          <vxe-button status="success" icon="vxe-icon-delete" content="删除" @click="importGridDel"/>
          <ExcelImport
            :ref="importGrid.excelRefs"
            :data-row="importGrid.dataRow"
            :value-match="importGrid.fieldArr"
            :accept="importGrid.accept"
            @changeExcel="uploadExamFile" />
        </div>
        <vxe-grid
          :id="importGrid.id"
          :ref="importGrid.gridRefs"
          :print-config="{}"
          :import-config="{}"
          :export-config="{}"
          :columns="importGrid.columns"
          :toolbar-config="importGrid.tableToolbar"
          :data="importGrid.data"
          :custom-config="{storage: true}"
          :edit-config="{trigger: 'click', mode: 'row', showStatus: true}"
          align="center"
          height="450"
          border
          resizable
          keep-source>
          <template #fcode_edit="{ row }">
            <vxe-input v-model="row.fcode"/>
          </template>
          <template #fname_edit="{ row }">
            <vxe-input v-model="row.fname"/>
          </template>
          <template #fzjqty_edit="{ row }">
            <vxe-input v-model="row.fzjqty"/>
          </template>
          <template #fqty_edit="{ row }">
            <vxe-input v-model="row.fqty"/>
          </template>
        </vxe-grid>
      </el-dialog>

      <el-dialog
        v-el-drag-dialog
        :visible.sync="configModal"
        :close-on-click-modal="false"
        width="85%"
        class="config-dialog">
        <head-table :config-list="configList" :key-value="key" @updateConfigData="getUpdateConfigData" />
      </el-dialog>

      <el-dialog v-el-drag-dialog :visible.sync="dialogSQLModal" :append-to-body="true" title="执行结果">
        <el-form v-loading="loadingFormSQL" ref="formSQL" :rules="rulesSQL" :model="formSQL" label-width="120px">
          <el-form-item label="SQL语句" prop="gzsql">
            <el-input v-model="formSQL.gzsql" :autosize="{ minRows: 14 }" type="textarea" />
          </el-form-item>
          <el-form-item>
            <el-button :loading="loadingFormSQL" type="primary" @click="confirmSQL">确认</el-button>
            <el-button @click="dialogSQLModal = false">取消</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>

      <el-dialog v-el-drag-dialog :visible.sync="dialogSendMsgModal" :append-to-body="true" width="50%" title="发送信息">
        <el-tree
          ref="selectTree"
          :props="defaultProps"
          :data="sendUsrList"
          node-key="id"
          show-checkbox
          @node-click="handleNodeClick"/>

        <br>

        <el-form ref="formSendMsg" :rules="rulesSendMsg" :model="formSendMsg" label-width="40px">
          <el-form-item label="内容" prop="fcontent">
            <el-input v-model="formSendMsg.fcontent" :autosize="{ minRows: 5 }" type="textarea" />
          </el-form-item>
          <el-form-item>
            <el-button :loading="loadingFormSendMsg" type="primary" @click="confirmSendMsg">确认</el-button>
            <el-button @click="dialogSendMsgModal = false">取消</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>

      <el-dialog
        v-el-drag-dialog
        :visible.sync="fcustDetailSettings.fdetailModal"
        :close-on-click-modal="false"
        :show-close="true"
        title="详情"
        class="cb-set-modal"
        width="50%">
        <div >

          <div style="margin-bottom: 20px">
            <el-input
              v-model="fcustDetailSettings.fdetailKeyword"
              clearable
              placeholder="搜索"
              style="width: 160px;"
              @keyup.native.enter="searchFcust"
              @change="searchFcust" />
            <el-button type="primary" @click="searchFcust">搜索</el-button>
            <el-button type="primary" @click="fcustConfirm">确认</el-button>
          </div>

          <el-table
            v-loading="fcustDetailSettings.fdetailLoading"
            v-if="limits.length >=1 && limits.filter(it => it.FName === '查看').length"
            ref="fcustTable"
            :data="fcustDetailSettings.fdetailData"
            :header-cell-style="tableHeaderStyle"
            max-height="600"
            class="tableCss single-select-table"
            element-loading-text="正在加载"
            border
            highlight-current-row
            @selection-change="fcustHandleSelectionChange">
            <el-table-column
              type="selection"
              width="55"/>
            <template v-for="item in fcustDetailSettings.detailFormThead">
              <el-table-column
                v-if="item.frpttypeflag ==0"
                :key="item.fid"
                :label="item.frepcap"
                :prop="item.frepfld"
                :width="item.frepwid"
                align="center"
                show-overflow-tooltip>
                <template slot-scope="scope">
                  <template v-if="item.frephide<=0">
                    <template v-if="item.frepfld === 'fstatus'">
                      <el-tag v-if="Number(scope.row[item.frepfld]) === 1" size="mini" type="success">已审</el-tag>
                      <el-tag v-else size="mini" type="danger">未审</el-tag>
                    </template>
                    <template v-else size="mini">
                      {{ scope.row[item.frepfld] }}
                    </template>
                  </template>
                </template>
              </el-table-column>
            </template>
          </el-table>
          <el-pagination
            v-if="limits.length >=1 && limits.filter(it => it.FName === '查看').length"
            :total="fcustDetailSettings.total"
            :page-sizes="fcustDetailSettings.pagesizes"
            :page-size="fcustDetailSettings.pagesize"
            :current-page.sync="fcustDetailSettings.currentPage"
            class="jy-pagination"
            style="text-align: center; margin-top: 20px;"
            background
            layout="sizes, prev, pager, next, total"
            @size-change="fcustHandleSizeChange"
            @current-change="fcustHandleCurrentChange"/>
        </div>
      </el-dialog>

      <el-dialog
        v-el-drag-dialog
        :visible.sync="fcdDetailSettings.fdetailModal"
        :close-on-click-modal="false"
        :show-close="true"
        title="详情"
        class="cb-set-modal"
        width="50%">
        <div >

          <div style="margin-bottom: 20px">
            <el-input
              v-model="fcdDetailSettings.fdetailKeyword"
              clearable
              placeholder="搜索"
              style="width: 160px;"
              @keyup.native.enter="searchFcd"
              @change="searchFcd" />
            <el-button type="primary" @click="searchFcd">搜索</el-button>
            <el-button type="primary" @click="fcdConfirm">确认</el-button>

          </div>
          <el-table
            v-loading="fcdDetailSettings.fdetailLoading"
            v-if="limits.length >=1 && limits.filter(it => it.FName === '查看').length"
            ref="fcdTable"
            :data="fcdDetailSettings.fdetailData"
            :header-cell-style="tableHeaderStyle"
            max-height="600"
            class="tableCss single-select-table"
            element-loading-text="正在加载"
            border
            highlight-current-row
            @selection-change="fcdHandleSelectionChange">
            <el-table-column
              type="selection"
              width="55"/>
            <template v-for="item in fcdDetailSettings.detailFormThead">
              <el-table-column
                v-if="item.frpttypeflag ==0"
                :key="item.fid"
                :label="item.frepcap"
                :prop="item.frepfld"
                :width="item.frepwid"
                align="center"
                show-overflow-tooltip>
                <template slot-scope="scope">
                  <template v-if="item.frephide<=0">
                    <template v-if="item.frepfld === 'fstatus'">
                      <el-tag v-if="Number(scope.row[item.frepfld]) === 1" size="mini" type="success">已审</el-tag>
                      <el-tag v-else size="mini" type="danger">未审</el-tag>
                    </template>
                    <template v-else size="mini">
                      {{ scope.row[item.frepfld] }}
                    </template>
                  </template>
                </template>
              </el-table-column>
            </template>
          </el-table>
          <el-pagination
            v-if="limits.length >=1 && limits.filter(it => it.FName === '查看').length"
            :total="fcdDetailSettings.total"
            :page-sizes="fcdDetailSettings.pagesizes"
            :page-size="fcdDetailSettings.pagesize"
            :current-page.sync="fcdDetailSettings.currentPage"
            class="jy-pagination"
            style="text-align: center; margin-top: 20px;"
            background
            layout="sizes, prev, pager, next, total"
            @size-change="fcdHandleSizeChange"
            @current-change="fcdHandleCurrentChange"/>
        </div>
      </el-dialog>

    </div>
    <div style=" margin-top:-20px; ">

      <vxe-grid
        ref="xGrid"
        :stripe="false"
        v-bind="gridOptions"
        :seq-config="{ startIndex: (tablePage.currentPage - 1) * tablePage.pageSize }"
        :footer-cell-class-name="footerCellClassName"
        @cell-dblclick="cellDbclick"
        @toolbar-button-click="toolbarButtonClickEvent">
        <template #fyjdate_edit="{ row }">
          <vxe-input v-model="row.fyjdate" :disabled="fyjDisabled" type="date" label-format="yyyy-MM" value-format="yyyy-MM" transfer @change="dateChangeEvent({ column })"/>
        </template>

      </vxe-grid>
    </div>

    <el-dialog
      v-el-drag-dialog
      :visible.sync="fmdDetailSettings.fdetailModal"
      :close-on-click-modal="false"
      :show-close="true"
      title="详情"
      class="cb-set-modal"
      width="60%">
      <div >
        <div class="search-top" style="margin-bottom: 20px;">
          <el-input
            v-model="fmdDetailSettings.fdetailKeyword"
            clearable
            placeholder="搜索"
            style="width: 160px;"
            @keyup.native.enter="searchFmd"
            @change="searchFmd" />
          <!-- <el-select v-model="fmdDetailSettings.fbrand" clearable placeholder="请选择品牌" @change="searchFmd">
          <el-option
            v-for="item in fmdDetailSettings.fbrandList"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <el-select v-model="fmdDetailSettings.fdanweibumen" clearable placeholder="请选择部门" @change="searchFmd">
          <el-option
            v-for="item in fmdDetailSettings.fdanweibumenList"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select> -->
          <el-button type="primary" @click="searchFmd">搜索</el-button>
          <el-button type="primary" @click="fmdConfirm">确认</el-button>
        </div>
        <el-table
          v-loading="fmdDetailSettings.fdetailLoading"
          v-if="limits.length >=1 && limits.filter(it => it.FName === '查看').length"
          ref="fmdTable"
          :data="fmdDetailSettings.fdetailData"
          :header-cell-style="tableHeaderStyle"
          max-height="600"
          class="tableCss single-select-table"
          element-loading-text="正在加载"
          border
          highlight-current-row
          @selection-change="fmdHandleSelectionChange">
          <el-table-column
            type="selection"
            width="55"/>
          <template v-for="item in fmdDetailSettings.detailFormThead">
            <el-table-column
              v-if="item.frpttypeflag ==0"
              :key="item.fid"
              :label="item.frepcap"
              :prop="item.frepfld"
              :width="item.frepwid"
              align="center"
              show-overflow-tooltip>

              <template slot-scope="scope">
                <template v-if="item.frephide<=0">
                  <template v-if="item.frepfld === 'fstatus'">
                    <el-tag v-if="Number(scope.row[item.frepfld]) === 1" size="mini" type="success">已审</el-tag>
                    <el-tag v-else size="mini" type="danger">未审</el-tag>
                  </template>
                  <template v-else size="mini">
                    {{ scope.row[item.frepfld] }}
                  </template>
                </template>
              </template>

            </el-table-column>
          </template>
        </el-table>

        <el-pagination
          v-if="limits.length >=1 && limits.filter(it => it.FName === '查看').length"
          :total="fmdDetailSettings.total"
          :page-sizes="fmdDetailSettings.pagesizes"
          :page-size="fmdDetailSettings.pagesize"
          :current-page.sync="fmdDetailSettings.currentPage"
          class="jy-pagination"
          style="text-align: center; margin-top: 20px;"
          background
          layout="sizes, prev, pager, next, total"
          @size-change="fmdHandleSizeChange"
          @current-change="fmdHandleCurrentChange"/>
      </div>
    </el-dialog>

  </div>

</template>
<script>
let FRepKey = ''
// let opername = ''
let fid = ''

import XEUtils from 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
import { vxetableBillConfig, tableConfig, apiSql, apiFileSave, XsbList, getDanHao, billGenAdd, admin } from '../../api/account'
import { sendsms, beijianTree, billGenEdit, FJZset } from '../../api/peijian'
import { configColumn } from '../../api/salary'
import { genList, FYWImportJZ } from '../../api/gen'
import { common } from '../../mixins/common'
import VXETablePluginShortcutKey from 'vxe-table-plugin-shortcut-key'
import '../../styles/vxetable.scss'
import HeadTable from '../salary/headTable/Billindex.vue'
// import { changeVal } from './js/marketAdd.js'

VXETable.use(VXETablePluginShortcutKey, {
  setting: {
    'table.edit.tab.rightMove': 'Enter',
    'table.edit.tab.leftMove': 'shift + Tab'

  }
})

export default {
  components: {
    HeadTable
  },
  mixins: [common],
  data() {
    return {
      importGrid: {
        rows: '',
        fmodel: '',
        fbrand: '',
        title: '加账成本（导入）',
        excelRefs: 'importExcel', // ExcelImport
        dataRow: 0, // 数据开始行 默认从第0行开始
        fieldArr: ['fcode', 'fname', 'fzjqty', 'fqty'], // 数据列 必须与excel中的表列顺序相对应
        valueTitle: ['代码', '名称', '装机数', '数量'],
        accept: '.xls,.xlsx',
        id: 'import-grid',
        gridRefs: 'importTable', // vxe-grid
        fmodal: false,
        data: [],
        columns: [
          { type: 'checkbox', width: 50 },
          { type: 'seq', width: 60 },
          { field: 'fcode', title: '代码', editRender: {}, slots: { edit: 'fcode_edit' }},
          { field: 'fname', title: '名称', editRender: {}, slots: { edit: 'fname_edit' }},
          { field: 'fzjqty', title: '装机数', editRender: {}, slots: { edit: 'fzjqty_edit' }},
          { field: 'fqty', title: '数量', editRender: {}, slots: { edit: 'fqty_edit' }}
        ]
      },

      multipleSelection: [],
      fmodelId: '',
      // FRepKey
      // opername
      // fbrand  --  WINGD和 MAN
      // fdanweibumen  ==  采购部  - 1 ，技术中心 --2 ,  其他部门--3 ，全部--0
      fbrand: 'WINGD',
      fbrandList: [
        { label: 'WINGD', value: 'WINGD' },
        { label: 'MAN', value: 'MAN' }
      ],
      fdanweibumen: '0',
      fdanweibumenList: [
        { label: '采购部', value: '1' },
        { label: '技术中心', value: '2' },
        { label: '其他部门', value: '3' },
        { label: '全部', value: '0' }
      ],
      fjzxmqd: {
        rows: '',
        fmodel: '',
        fbrand: ''
      },
      fmodelKeyword: '',
      fmodelLoading: false,
      fmodelModal: false,
      fmodelListData: [],
      isAddShow: true,
      formData: {

      },
      dialogThead: [],
      columnHeaderData: [],
      columnData: [],
      opername: '',
      aaValue: '',
      oriColumnData: [],

      configList: [],
      configModal: false,
      menusList: [],
      limits: [],
      lookSetShow: false,
      key: 0,
      dialogSQLModal: false,
      loadingFormSQL: false,
      formSQL: {
        gzsql: ''
      },
      rulesSQL: {
      },

      dialogSendMsgModal: false,
      loadingFormSendMsg: false,
      userList: [],
      sendUsrList: [],
      formSendMsg: {

      },
      rulesSendMsg: {

      },
      defaultProps: {
        children: 'children',
        label: 'label'
      },

      tablePage: {
        total: 0,
        currentPage: 1,
        pageSize: 20
      },
      vxeDisabled: false,

      // 项目客户
      fcustDetailSettings: {
        header: [], // 表头字段（值）
        headerKeys: [], // 表头字段（键） filterVal
        listData: [], // 表体数据
        fmodel: '',
        fbrand: '',
        fbrandList: [
          { label: 'WINGD', value: 'WINGD' },
          { label: 'MAN', value: 'MAN' }
        ],
        fdanweibumen: '0',
        fdanweibumenList: [
          { label: '采购部', value: '1' },
          { label: '技术中心', value: '2' },
          { label: '其他部门', value: '3' },
          { label: '全部', value: '0' }
        ],
        // keyword: '',
        fdetailModal: false, // 1
        fdetailKeyword: '', // 1
        fdetailLoading: false, // 1
        detailFormThead: [], // 1
        detailDialogThead: [],
        fdetailData: [], // 1
        fdetailList: [],
        // 页脚
        total: 0,
        pagesize: 10,
        pagesizes: [10, 20, 50, 100],
        currentPage: 1,
        FRepKey: 14022,
        multipleSelection: [],
        fmodelId: ''
      },

      // 船东
      fcdDetailSettings: {
        header: [], // 表头字段（值）
        headerKeys: [], // 表头字段（键） filterVal
        listData: [], // 表体数据
        fmodel: '',
        fbrand: '',
        fbrandList: [
          { label: 'WINGD', value: 'WINGD' },
          { label: 'MAN', value: 'MAN' }
        ],
        fdanweibumen: '0',
        fdanweibumenList: [
          { label: '采购部', value: '1' },
          { label: '技术中心', value: '2' },
          { label: '其他部门', value: '3' },
          { label: '全部', value: '0' }
        ],
        // keyword: '',
        fdetailModal: false, // 1
        fdetailKeyword: '', // 1
        fdetailLoading: false, // 1
        detailFormThead: [], // 1
        detailDialogThead: [],
        fdetailData: [], // 1
        fdetailList: [],
        // 页脚
        total: 0,
        pagesize: 10,
        pagesizes: [10, 20, 50, 100],
        currentPage: 1,
        FRepKey: 14023,
        multipleSelection: [],
        fmodelId: ''
      },

      // 型号
      fmdDetailSettings: {
        header: [], // 表头字段（值）
        headerKeys: [], // 表头字段（键） filterVal
        listData: [], // 表体数据
        fmodel: '',
        fbrand: '',
        fbrandList: [
          { label: 'WINGD', value: 'WINGD' },
          { label: 'MAN', value: 'MAN' }
        ],
        fdanweibumen: '0',
        fdanweibumenList: [
          { label: '采购部', value: '1' },
          { label: '技术中心', value: '2' },
          { label: '其他部门', value: '3' },
          { label: '全部', value: '0' }
        ],
        // keyword: '',
        fdetailModal: false, // 1
        fdetailKeyword: '', // 1
        fdetailLoading: false, // 1
        detailFormThead: [], // 1
        detailDialogThead: [],
        fdetailData: [], // 1
        fdetailList: [],
        // 页脚
        total: 0,
        pagesize: 10,
        pagesizes: [10, 20, 50, 100],
        currentPage: 1,
        FRepKey: 14007,
        multipleSelection: [],
        fmodelId: ''
      },

      keyword: '',
      isHebing: '0',
      isSave: false,
      fisyongjinblOptions: [ // 是否佣金比例
        { label: '比例', value: '比例' },
        { label: '金额', value: '金额' },
        { label: '无', value: '无' }
      ],
      fisegrOptions: [ // 是否含EGR   是否有加账  是否借船厂遥控系统
        { label: 'EcoEGR', value: 'EcoEGR' },
        { label: 'EGRBP', value: 'EGRBP' },
        { label: '否', value: '否' }],
      fisjingneijingwaiVal: '', // 境内/境外佣金
      fisjingneijingwaiOptions: [],
      gridOptions: {
        border: true,
        showHeaderOverflow: true,
        showOverflow: true,
        showFooterOverflow: true,
        keepSource: true,
        autoResize: true,
        resizable: true,

        height: this.heightGD(),
        showFooter: true,
        round: true,
        size: 'mini',

        id: 'full_edit_1',
        rowId: 'id',
        rowConfig: {
          isHover: true,
          isCurrent: true
        },
        // columnConfig: {
        //   resizable: true
        // },

        // 自定义列配置项
        customConfig: {
          storage: true,
          checkMethod: this.checkColumnMethod
        },

        keyboardConfig: {
          isEnter: true,
          isArrow: true
        },
        editRules: {
          fcustomer: [
            { required: true, message: '必须填写' }
          ],
          fcustomername: [
            { required: true, message: '必须填写' }
          ],
          fmodelno: [
            { required: true, message: '必须填写' }
          ],
          fjsxyno: [
            { required: true, message: '必须填写' }
          ],
          fmodel: [
            { required: true, message: '必须填写' }
          ],
          fsxtaishu: [ // // 生效台数
            { required: true, message: '必须填写' },
            { pattern: '^[1-9][0-9]*([0-9]*|([\+?][1-9][0-9]*)*)$', message: '输入格式不合符要求，要求格式为数字, 数字+数字, 数字+数字+...+数字，不含空格' }
            // { pattern: '^((\s+)[1-9]|[1-9])[0-9]*(([0-9]*|([\+?][1-9][0-9]*)*)|([0-9]*|([\+?][1-9][0-9]*)*)(\s+))$', message: '输入格式不合符要求，要求格式为数字, 数字+数字, 数字+数字+...+数字，不含空格' }
          ],
          fsjpower: [
            { required: true, message: '必须填写' },
            { validator: (val) => {
              const { cellValue, row } = val
              // 合同功率<= 设计功率
              if (Number(cellValue) < Number(row.fhtpower)) {
                return new Error('设计功率不能小于合同功率')
              }
            },
            message: '合同功率不能大于设计功率',
            trigger: 'change'
            }
          ],
          fhtpower: [
            { required: true, message: '必须填写' },
            { validator: (val) => {
              const { cellValue, row } = val
              // 合同功率<= 设计功率
              if (Number(cellValue) > Number(row.fsjpower)) {
                return new Error('合同功率不能大于设计功率')
              }
            },
            message: '合同功率不能大于设计功率',
            trigger: 'change'
            }
          ],
          fzhujiranliaos: [
            { required: true, message: '必须填写' }
          ],
          fisscr: [
            { required: true, message: '必须填写' }
          ],
          fisryrq: [
            { required: true, message: '必须填写' }
          ],
          fscrlowup: [
            { required: true, message: '必须填写' }
          ],
          fisegr: [
            { required: true, message: '必须填写' }
          ],
          fegrlowup: [
            { required: true, message: '必须填写' }
          ],
          fmpctriton: [
            { required: true, message: '必须填写' }
          ],
          fisjiazhang: [
            { required: true, message: '必须填写' }
          ],
          fchuanjishe: [
            { required: true, message: '必须填写' }
          ],
          fgvuigpr: [
            { required: true, message: '必须填写' }
          ],
          fzhibaoqi: [
            { required: true, message: '必须填写' }
          ],
          fyjdate: [
            { required: true, message: '必须填写' }
          ],
          fisyongjinbl: [
            { required: true, message: '必须填写' }
          ],

          fyongjin: [
            { required: true, message: '必须填写' }
          ],
          fyongjinbl: [
            { required: true, message: '必须填写' }
          ],
          fyongjinjine: [
            { required: true, message: '必须填写' }
          ],
          fisjingneijingwai: [
            { required: true, message: '必须填写' }
          ],
          fyunbaof: [
            { required: true, message: '必须填写' }
          ],
          fzengsong: [
            { required: true, message: '必须填写' }
          ],

          fisyaokongsys: [
            { required: true, message: '必须填写' }
          ]

          // fmodelno: [
          //   { required: true, message: '不能为空' }
          // ],
          // fmodel: [
          //   { required: true, message: '不能为空' }
          // ],
          // fsxtaishu: [
          //   { required: true, message: '不能为空' }
          // ],
          // fsjpower: [
          //   { required: true, message: '不能为空' }
          // ],
          // fhtpower: [
          //   { required: true, message: '不能为空' }
          // ]
        },
        toolbarConfig: {
          size: 'medium',
          custom: true,
          buttons: [
            {
              name: '设置',
              disabled: false,
              // visible: false,
              status: 'success',
              dropdowns: [
                { code: 'dataSettings', name: '单据设置', type: 'text', disabled: false },
                { code: 'sqlSettings', name: '显示SQL语句', type: 'text', disabled: false }
              ]
            },
            // { code: 'myAdd', name: '新增', icon: 'vxe-icon-add', status: 'success' },
            // { code: 'myDelete', name: '删除', icon: 'vxe-icon-delete', status: 'success' },
            { code: 'save', name: '保存', icon: 'vxe-icon-save', status: 'success' },
            { code: 'mySend', name: '发送消息', icon: 'vxe-icon-send-fill', status: 'success' },
            { code: 'myFresh', name: '刷新', icon: 'vxe-icon-refresh', status: 'success' },
            { code: 'myBack', name: '返回', icon: 'vxe-icon-arrow-left', status: 'success' }
          ]
        },
        proxyConfig: {
          autoLoad: false,
          message: false,
          seq: true, // 启用动态序号代理，每一页的序号会根据当前页数变化
          // sort: true, // 启用排序代理，当点击排序时会自动触发 query 行为
          // filter: true, // 启用筛选代理，当点击筛选时会自动触发 query 行为
          // form: true, // 启用表单代理，当点击表单提交按钮时会自动触发 reload 行为
          // 对应响应结果 { result: [], page: { total: 100 } }
          props: {
            result: 'result', // 配置响应结果列表字段
            total: 'page.total' // 配置响应结果总页数字段
          },
          // 只接收Promise，具体实现自由发挥
          ajax: {
            // 当点击工具栏查询按钮或者手动提交指令 query或reload 时会被触发
            // query: ({ page, sorts, filters, form }) => {
            //   console.log(page, sorts, filters, form)
            // },
            // 当点击工具栏保存按钮或者手动提交指令 save 时会被触发
            save: async() => {
              this.isSave = true
              await this.vxeSave()
              console.log(' ajax save ')
            }
          }
        },
        columns: [],
        // data: [],

        checkboxConfig: {
          // labelField: 'id',
          reserve: true,
          highlight: true,
          range: true
        },

        editConfig: {
          trigger: 'click',
          mode: 'row',
          showStatus: true, // 是否显示单元格新增与修改状态
          showIcon: false // 是否显示列头编辑图标
          // activeMethod: this.activeRowMethod
        }

      },
      fyjDisabled: false

    }
  },
  Mounted: {

  },
  computed: {

  },
  async created() {
    FRepKey = this.$route.query.key
    fid = Number(this.$route.query.fid)
    // 这里有fid -- 修改
    // opername = decodeURIComponent(this.globalDb.fname)
    this.opername = decodeURIComponent(this.globalDb.fname)

    // await this.getAdmin()

    await this.getvxetableBillConfig()
    await this.getGenListData()

    if (fid) {
      this.isAddShow = false
      await this.getBillGenEdit()
      // $grid.insertAt(row, -1)
    } else {
      const $grid = this.$refs.xGrid
      for (let i = 0; i < 1; i++) {
        setTimeout(() => {
          $grid.insertAt(-1, -1)
        }, 0)
      }
      console.log(fid, ' fid')
      // await this.getvxetableGenList()
      // await this.getliushuihao()
    }

    this.lookSetShow = JSON.parse(localStorage.getItem('flookSet'))
    this.gridOptions.toolbarConfig.buttons[0].visible = this.lookSetShow

    // 菜单列表（权限）
    const menuRes = JSON.parse(localStorage.getItem('setMenuData'))
    this.menusList = menuRes

    if (menuRes.length >= 1) {
      menuRes.map(it => {
        it.children.map(item => {
          if (item.fobjectid === parseInt(FRepKey)) {
            this.$set(this, 'limits', item.child)
          }
        })
      })
    }

    // console.log(menuRes, this.limits, 888888)
  },
  methods: {
    // 获取数据
    uploadExamFile(data) {
      console.log('导出的数据', data)
      this.importGrid.data = data
    },
    importData() {
      this.importGrid.fmodal = true
      this.importGridDel()
    },
    toImport() {
      this.$refs[this.importGrid.excelRefs].open()
    },
    importGridAdd() { // 新增
      const $grid = this.$refs[this.importGrid.gridRefs]
      $grid.insertAt(-1, -1)
    },
    importGridDel() { // 删除当前行
      const $grid = this.$refs[this.importGrid.gridRefs]
      if ($grid) {
        const checkData = $grid.getCheckboxRecords()
        if (checkData.length) {
          $grid.removeCheckboxRow()
        } else {
          this.importGrid.data = []
          $grid.remove($grid.getCheckboxRecords())
        }
      }
    },
    async importGridSave() { // 保存
      const $grid = this.$refs[this.importGrid.gridRefs]
      $grid.getRecordset()
      const { fullData } = $grid.getTableData()
      // console.log(tableData, ' importGridSave tableData')

      try {
        const res = await FYWImportJZ({
          FRepKey,
          fbillno: this.formData.fbillno,
          rows: this.importGrid.rows,
          opername: this.opername,
          fmodel: this.importGrid.fmodel,
          fbrand: this.importGrid.fbrand,
          data: fullData
        })
        if (res.Error === 0) {
          this.$message({
            message: res.Message,
            type: 'success'
          })
          this.importGrid.fmodel = ''
          this.importGrid.fbrand = ''
          this.importGrid.fmodal = false
          console.log(this.importGrid, ' this.importGrid')
        } else {
          this.$message({
            message: res.Message,
            type: 'error'
          })
        }
      } catch (error) {
        console.log(error)
      }
    },
    // 导入数据上面----------------
    async searchFmd() {
      await this.getFmdBodyData()
      await this.getFmdHeadData()
    },
    async fmdHandleSizeChange(val) {
      this.fmdDetailSettings.currentPage = 1
      this.fmdDetailSettings.pagesize = val
      await this.getFmdBodyData()
      await this.getFmdHeadData()
    },
    async fmdHandleCurrentChange(val) {
      this.fmdDetailSettings.currentPage = val
      await this.getFmdBodyData()
      await this.getFmdHeadData()
    },
    // 表头数据
    async getFmdHeadData() {
      try {
        this.fmdDetailSettings.fdetailLoading = true
        this.header = []
        this.headerKeys = []
        this.listData = []
        const res = await configColumn({
          db: this.globalDb.db,
          opername: this.opername,
          FRepKey: this.fmdDetailSettings.FRepKey
        })
        this.fmdDetailSettings.fdetailLoading = false
        if (res.Error === 0) {
          if (res.Data.length) {
            this.fmdDetailSettings.detailFormThead = res.Data
          } else {
            this.fmdDetailSettings.detailFormThead = []
          }
        }
        // 机型  功率 生效台数 流水号
        this.fmdDetailSettings.detailFormThead.map(item => {
          this.fmdDetailSettings.fdetailList.map(it => {
            if (item.freptype === 131) {
              it[item.frepfld] = Number(it[item.frepfld]).toFixed(item.fdecplaces)
            }
          })
        })
        this.fmdDetailSettings.fdetailData = this.fmdDetailSettings.fdetailList.slice()
        // 获取显示表头键值对
        this.fmdDetailSettings.detailFormThead.filter(item => {
          // if (!item.frephide) {
          if (!item.frephide) {
            this.header.push(item.frepcap)
            this.headerKeys.push(item.frepfld)
          }
        })
        // 获取显示表体数据
        const listData = this.fmdDetailSettings.fdetailList.slice()
        listData.map((item, index) => {
          this.listData[index] = {}
          this.headerKeys.map(it => {
            this.listData[index][it] = item[it]
          })
        })
        // console.log(this.fmdDetailSettings.detailFormThead, ' this.fmdDetailSettings.detailFormThead')
        // 去除内码
        const arr = res.Data.slice()
        arr.map((item, index) => {
          if (item.frepfld === 'fid') {
            arr.splice(index, 1)
          }
        })
        // this.dialogThead = arr.filter(item => item.funcontrol !== 1)
      } catch (error) {
        this.fmdDetailSettings.fdetailLoading = false
      }
    },
    // 表体数据————erp职员列表
    async getFmdBodyData() {
      try {
        this.fmdDetailSettings.fdetailLoading = true
        const res = await genList({
          db: this.globalDb.db,
          opername: this.opername,
          keyword: this.fmdDetailSettings.fdetailKeyword,
          fstatus: '',
          limit: this.fmdDetailSettings.pagesize,
          page: this.fmdDetailSettings.currentPage,
          FRepKey: this.fmdDetailSettings.FRepKey
        })
        this.fmdDetailSettings.fdetailLoading = false
        this.fmdDetailSettings.fdetailList = res.Data
        this.fmdDetailSettings.total = res.total
      } catch (error) {
        this.fmdDetailSettings.fdetailLoading = false
      }
    },
    fmdConfirm() {
      const $grid = this.$refs.xGrid
      const { tableData } = $grid.getTableData()
      const selected = this.fmdDetailSettings.multipleSelection
      console.log(selected, ' selected')
      if (!selected.length) {
        this.$message({
          message: '请选中一行',
          type: 'warning'
        })
        return
      }
      // console.log(this.fmdDetailSettings.multipleSelection, ' this.fmdDetailSettings.multipleSelection')
      tableData.map(it => {
        if (it.id === this.fmdDetailSettings.fmodelId) {
          this.$set(it, 'fmodel', selected[0].fmodel)
          this.$set(it, 'fsjpower', selected[0].fpower)
          // this.$set(it, 'fhtzhuansu', selected[0].fzhuansu)
          this.$set(this.importGrid, 'fmodel', selected[0].fmodel)
          this.$set(this.importGrid, 'fbrand', selected[0].fbrand)
        }
      })
      this.fmdDetailSettings.fdetailModal = false
      this.$refs.fmdTable.clearSelection()
      this.fmdDetailSettings.multipleSelection = []
    },
    fmdHandleSelectionChange(val) {
      if (val.length) {
        this.fmdDetailSettings.multipleSelection = val
      } else {
        this.fmdDetailSettings.multipleSelection = []
      }
      if (val.length > 1) {
        this.$refs.fmdTable.clearSelection()
        this.$refs.fmdTable.toggleRowSelection(val.pop())
      }
    },

    async searchFcust() {
      await this.getFcustBodyData()
      await this.getFcustHeadData()
    },
    async fcustHandleSizeChange(val) {
      this.fcustDetailSettings.currentPage = 1
      this.fcustDetailSettings.pagesize = val
      await this.getFcustBodyData()
      await this.getFcustHeadData()
    },
    async fcustHandleCurrentChange(val) {
      this.fcustDetailSettings.currentPage = val
      await this.getFcustBodyData()
      await this.getFcustHeadData()
    },
    // 表头数据
    async getFcustHeadData() {
      try {
        this.fcustDetailSettings.fdetailLoading = true
        this.header = []
        this.headerKeys = []
        this.listData = []
        const res = await configColumn({
          db: this.globalDb.db,
          opername: this.opername,
          FRepKey: this.fcustDetailSettings.FRepKey
        })
        this.fcustDetailSettings.fdetailLoading = false
        if (res.Error === 0) {
          if (res.Data.length) {
            this.fcustDetailSettings.detailFormThead = res.Data
          } else {
            this.fcustDetailSettings.detailFormThead = []
          }
        }
        // 机型  功率 生效台数 流水号
        this.fcustDetailSettings.detailFormThead.map(item => {
          this.fcustDetailSettings.fdetailList.map(it => {
            if (item.freptype === 131) {
              it[item.frepfld] = Number(it[item.frepfld]).toFixed(item.fdecplaces)
            }
          })
        })
        this.fcustDetailSettings.fdetailData = this.fcustDetailSettings.fdetailList.slice()
        // 获取显示表头键值对
        this.fcustDetailSettings.detailFormThead.filter(item => {
          // if (!item.frephide) {
          if (!item.frephide) {
            this.header.push(item.frepcap)
            this.headerKeys.push(item.frepfld)
          }
        })
        // 获取显示表体数据
        const listData = this.fcustDetailSettings.fdetailList.slice()
        listData.map((item, index) => {
          this.listData[index] = {}
          this.headerKeys.map(it => {
            this.listData[index][it] = item[it]
          })
        })
        // console.log(this.fcustDetailSettings.detailFormThead, ' this.fcustDetailSettings.detailFormThead')
        // 去除内码
        const arr = res.Data.slice()
        arr.map((item, index) => {
          if (item.frepfld === 'fid') {
            arr.splice(index, 1)
          }
        })
        // this.dialogThead = arr.filter(item => item.funcontrol !== 1)
      } catch (error) {
        this.fcustDetailSettings.fdetailLoading = false
      }
    },
    // 表体数据————erp职员列表
    async getFcustBodyData() {
      try {
        this.fcustDetailSettings.fdetailLoading = true
        const res = await genList({
          db: this.globalDb.db,
          opername: this.opername,
          keyword: this.fcustDetailSettings.fdetailKeyword,
          fstatus: '',
          limit: this.fcustDetailSettings.pagesize,
          page: this.fcustDetailSettings.currentPage,
          FRepKey: this.fcustDetailSettings.FRepKey
        })
        this.fcustDetailSettings.fdetailLoading = false
        this.fcustDetailSettings.fdetailList = res.Data
        this.fcustDetailSettings.total = res.total
      } catch (error) {
        this.fcustDetailSettings.fdetailLoading = false
      }
    },
    fcustConfirm() {
      const $grid = this.$refs.xGrid
      const { tableData } = $grid.getTableData()
      const selected = this.fcustDetailSettings.multipleSelection
      console.log(selected, ' selected')
      if (!selected.length) {
        this.$message({
          message: '请选中一行',
          type: 'warning'
        })
        return
      }
      tableData.map(it => {
        if (it.id === this.fcustDetailSettings.fmodelId) {
          this.$set(it, 'fcustomer', selected[0].fname)
        }
      })
      this.fcustDetailSettings.fdetailModal = false
      this.$refs.fcustTable.clearSelection()
      this.fcustDetailSettings.multipleSelection = []
    },
    fcustHandleSelectionChange(val) {
      if (val.length) {
        this.fcustDetailSettings.multipleSelection = val
      } else {
        this.fcustDetailSettings.multipleSelection = []
      }
      if (val.length > 1) {
        this.$refs.fcustTable.clearSelection()
        this.$refs.fcustTable.toggleRowSelection(val.pop())
      }
    },

    async searchFcd() {
      await this.getFcdBodyData()
      await this.getFcdHeadData()
    },
    async fcdHandleSizeChange(val) {
      this.fcdDetailSettings.currentPage = 1
      this.fcdDetailSettings.pagesize = val
      await this.getFcdBodyData()
      await this.getFcdHeadData()
    },
    async fcdHandleCurrentChange(val) {
      this.fcdDetailSettings.currentPage = val
      await this.getFcdBodyData()
      await this.getFcdHeadData()
    },
    // 表头数据
    async getFcdHeadData() {
      try {
        this.fcdDetailSettings.fdetailLoading = true
        this.header = []
        this.headerKeys = []
        this.listData = []
        const res = await configColumn({
          db: this.globalDb.db,
          opername: this.opername,
          FRepKey: this.fcdDetailSettings.FRepKey
        })
        this.fcdDetailSettings.fdetailLoading = false
        if (res.Error === 0) {
          if (res.Data.length) {
            this.fcdDetailSettings.detailFormThead = res.Data
          } else {
            this.fcdDetailSettings.detailFormThead = []
          }
        }
        // 机型  功率 生效台数 流水号
        this.fcdDetailSettings.detailFormThead.map(item => {
          this.fcdDetailSettings.fdetailList.map(it => {
            if (item.freptype === 131) {
              it[item.frepfld] = Number(it[item.frepfld]).toFixed(item.fdecplaces)
            }
          })
        })
        this.fcdDetailSettings.fdetailData = this.fcdDetailSettings.fdetailList.slice()
        // 获取显示表头键值对
        this.fcdDetailSettings.detailFormThead.filter(item => {
          // if (!item.frephide) {
          if (!item.frephide) {
            this.header.push(item.frepcap)
            this.headerKeys.push(item.frepfld)
          }
        })
        // 获取显示表体数据
        const listData = this.fcdDetailSettings.fdetailList.slice()
        listData.map((item, index) => {
          this.listData[index] = {}
          this.headerKeys.map(it => {
            this.listData[index][it] = item[it]
          })
        })
        // console.log(this.fcdDetailSettings.detailFormThead, ' this.fcdDetailSettings.detailFormThead')
        // 去除内码
        const arr = res.Data.slice()
        arr.map((item, index) => {
          if (item.frepfld === 'fid') {
            arr.splice(index, 1)
          }
        })
        // this.dialogThead = arr.filter(item => item.funcontrol !== 1)
      } catch (error) {
        this.fcdDetailSettings.fdetailLoading = false
      }
    },
    // 表体数据————erp职员列表
    async getFcdBodyData() {
      try {
        this.fcdDetailSettings.fdetailLoading = true
        const res = await genList({
          db: this.globalDb.db,
          opername: this.opername,
          keyword: this.fcdDetailSettings.fdetailKeyword,
          fstatus: '',
          limit: this.fcdDetailSettings.pagesize,
          page: this.fcdDetailSettings.currentPage,
          FRepKey: this.fcdDetailSettings.FRepKey
        })
        this.fcdDetailSettings.fdetailLoading = false
        this.fcdDetailSettings.fdetailList = res.Data
        this.fcdDetailSettings.total = res.total
      } catch (error) {
        this.fcdDetailSettings.fdetailLoading = false
      }
    },
    fcdConfirm() {
      const $grid = this.$refs.xGrid
      const { tableData } = $grid.getTableData()
      const selected = this.fcdDetailSettings.multipleSelection
      console.log(selected, ' selected')
      if (!selected.length) {
        this.$message({
          message: '请选中一行',
          type: 'warning'
        })
        return
      }
      tableData.map(it => {
        if (it.id === this.fcdDetailSettings.fmodelId) {
          this.$set(it, 'fcustomername', selected[0].fname)
        }
      })
      this.fcdDetailSettings.fdetailModal = false
      this.$refs.fcdTable.clearSelection()
      this.fcdDetailSettings.multipleSelection = []
    },
    fcdHandleSelectionChange(val) {
      if (val.length) {
        this.fcdDetailSettings.multipleSelection = val
      } else {
        this.fcdDetailSettings.multipleSelection = []
      }
      if (val.length > 1) {
        this.$refs.fcdTable.clearSelection()
        this.$refs.fcdTable.toggleRowSelection(val.pop())
      }
    },
    async selectBrand() {
      await this.getGenListData()
    },
    // 表体数据————erp职员列表
    async getGenListData() {
      try {
        this.listLoading = true
        const res = await FJZset({
          db: this.globalDb.db,
          opername: this.opername,
          keyword: this.fmodelKeyword,
          fbrand: this.fbrand,
          fdanweibumen: this.fdanweibumen,
          limit: 50,
          page: 1,
          FRepKey: 14009
        })
        // this.listLoading = false

        if (res.Error === 0) {
          this.$message({
            message: res.Message,
            type: 'success'
          })

          this.fmodelListData = res.Data
        } else {
          this.$message({
            message: res.Message,
            type: 'error'
          })
        }
      } catch (error) {
        // this.listLoading = false
      }
    },
    activeRowMethod({ row, column, columnIndex }) {
      console.log(10000, row, column, columnIndex)
    },
    async searchFmodel() {
      await this.getGenListData()
    },
    closeDialog() {
      this.importGrid.fmodel = ''
      this.importGrid.fbrand = ''
      this.importGrid.rows = ''
      this.importGridDel()
      this.$refs.fmdTable.clearSelection()
    },
    async fmodelConfirm() {
      // const $grid = this.$refs.xGrid
      // const { tableData } = $grid.getTableData()
      // tableData.map(it => {
      //   if (it.id === this.fmodelId) {
      //     this.$set(it, 'jiazhangdata', this.multipleSelection)
      //   }
      // })
      try {
        const res = await FYWImportJZ({
          FRepKey,
          fbillno: this.formData.fbillno,
          rows: this.fjzxmqd.rows,
          opername: this.opername,
          fmodel: this.fjzxmqd.fmodel,
          fbrand: this.fjzxmqd.fbrand,
          data: this.multipleSelection
        })
        if (res.Error === 0) {
          this.$message({
            message: res.Message,
            type: 'success'
          })
          this.fjzxmqd.fmodel = ''
          this.fjzxmqd.fbrand = ''
          this.fmodelModal = false
          this.$refs.fmdTable.clearSelection()
        } else {
          this.$message({
            message: res.Message,
            type: 'error'
          })
        }
      } catch (error) {
        console.log(error)
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    dateChangeEvent({ row, column }) {
    },
    editActive({ row }) {
      console.log(row, ' row')
    },
    // 获取流水号
    async getliushuihao() {
      const res = await getDanHao({
        db: this.globalDb.db,
        opername: this.opername,
        FRepKey
      })
      setTimeout(() => {
        this.$set(this.formData, 'fbillno', res.Data)
        // console.log(this.formData, 'this.formData getliushuihao')
      }, 0)
      // this.formData.fbillno = res.Data
    },

    editDisabledEvent({ row }) { },

    editClosedEvent({ row }) { },

    // 高度
    heightGD() {
      return (document.body.offsetHeight - 185) + 'px'
    },
    settings() {
      this.configModal = true
      this.getTableConfig()
    },
    async getTableConfig() {
      try {
        this.configLoading = true
        const res = await tableConfig({
          db: this.globalDb.db,
          opername: this.opername,
          key: FRepKey,
          billtype: 1
        })
        this.configList = res.Data
        this.key = Number(FRepKey)
        this.configLoading = false
      } catch (error) {
        this.configLoading = false
      }
    },

    // SQL修改/更新
    async dialogSQL() {
      this.dialogSQLModal = true
      try {
        const res = await apiSql({
          db: this.globalDb.db,
          opername: this.opername,
          type: 1,
          FRepKey
        })

        if (res.Error === 0) {
          this.formSQL.gzsql = res.Data
          this.formSQL.FRepKey = FRepKey
        }
        setTimeout(() => {
          this.$refs['formSQL'].clearValidate()
        })
      } catch (error) {
        // console.log(error)
      }
    },

    confirmSQL() {
      this.$refs['formSQL'].validate(async(valid) => {
        if (valid) {
          try {
            this.formSQL.db = this.globalDb.db
            this.formSQL.opername = this.opername
            this.formSQL.type = 1
            const res = await apiFileSave(this.formSQL)
            if (res.Error === 0) {
              this.dialogSQLModal = false
              this.$message({
                message: res.Message,
                type: 'success'
              })
            } else {
              this.$message({
                message: res.Message,
                type: 'error'
              })
            }
          } catch (error) {
            // console.log(error)
          }
        } else {
          return false
        }
      })
    },
    async cellDbclick({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }) {
      console.log(row, ' row')
      if (column.field === 'fisjiazhang' && fid) {
        this.fjzxmqd.rows = row
        this.fjzxmqd.fmodel = row.fmodel
        this.fjzxmqd.fbrand = row.fbrand
        // console.log(fid, ' fid')
        this.fmodelId = row.id
        this.importGrid.rows = row
        this.importGrid.fmodel = row.fmodel
        this.fmodelModal = true
        if (row.jiazhangdata && row.jiazhangdata.length) {
          // console.log(row.jiazhangdata, ' row.jiazhangdata')
          // console.log(row.jiazhangdata.length, ' row.jiazhangdata')
          const jzData = JSON.parse(JSON.stringify(row.jiazhangdata))
          this.$nextTick(() => {
            this.fmodelListData.map(row => {
              jzData.map(jz => {
                if (row.fid === jz.fid) {
                  this.$refs.fmdTable.toggleRowSelection(row, true)
                }
              })
            })
          })
        }
      }
      if (column.field === 'fcustomer') { // 项目客户
        this.fcustDetailSettings.fmodelId = row.id
        this.fcustDetailSettings.fdetailModal = true
        // 弹窗数据
        await this.getFcustBodyData()
        await this.getFcustHeadData()
      }
      if (column.field === 'fcustomername') { // 船东
        console.log(111)
        this.fcdDetailSettings.fmodelId = row.id
        this.fcdDetailSettings.fdetailModal = true
        // 弹窗数据
        await this.getFcdBodyData()
        await this.getFcdHeadData()
      }

      if (column.field === 'fmodel') {
        this.fmdDetailSettings.fmodelId = row.id
        this.fmdDetailSettings.fdetailModal = true
        // 弹窗数据
        await this.getFmdBodyData()
        await this.getFmdHeadData()
      }
    },
    // 更新数据
    async getUpdateConfigData() {
      await this.getTableConfig()
    },

    // 添加表格背景颜色
    footerCellClassName({ $rowIndex, columnIndex }) {
      // if (columnIndex === 0) {
      if ($rowIndex === 0) {
        // return 'col-blue'
        // }
      }
    },
    async changeVal({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex }) {
      // console.log(column.field, ' column.field')
      // console.log(row, ' row')
      const $grid = this.$refs.xGrid
      const colField = $grid.getColumnByField('fisjingneijingwai')
      const colFieldFyongjinjine = $grid.getColumnByField('fyongjinjine')
      const colFieldFyongjinbl = $grid.getColumnByField('fyongjinbl')

      const fisryrq = $grid.getColumnByField('fisryrq') // fisryrq ICER版本（燃气或者燃油版）开始

      const fisscr = $grid.getColumnByField('fisscr') // fisscr 是否含SCR
      const fscrlowup = $grid.getColumnByField('fscrlowup') // fscrlowup 含SCR低高硫

      const fisegr = $grid.getColumnByField('fisegr') // fisegr 是否含EGR
      const fegrlowup = $grid.getColumnByField('fegrlowup') // fegrlowup 含EGR低高硫

      // fisyaokongsys 是否借船厂遥控系统
      // fisykstyunfei // 借遥控系统运费
      const colFieldFisykstyunfei = $grid.getColumnByField('fisykstyunfei')
      console.log(column, ' column')
      console.log(colField, ' colField')
      // console.log(row[column.field], ' row[column.field]')
      // fyongjinjine  佣金金额(元)
      // fisyongjinbl 佣金
      console.log(column.field, column.frepcap, ' column.frepcap')
      switch (column.field) {
        case 'fisyongjinbl':// 是否佣金比例
          if (row[column.field] === '无') {
            colField.editRender.options = [
              { label: '无', value: '无' }
            ]
            this.$set(row, 'fisjingneijingwai', '无') // 境内/境外佣金
            this.$set(row, 'fyongjinbl', 0) // 佣金比例
            this.$set(row, 'fyongjinjine', 0) // 佣金金额(元)
            colFieldFyongjinjine.editRender.props.disabled = true
            colFieldFyongjinbl.editRender.props.disabled = true
          } else {
            colField.editRender.options = [
              { label: '境内', value: '境内' },
              { label: '境外', value: '境外' }
            ]
            this.$set(row, 'fisjingneijingwai', '')
            if (row[column.field] === '比例') {
              this.$set(row, 'fyongjinjine', 0)
              colFieldFyongjinjine.editRender.props.disabled = true
              colFieldFyongjinbl.editRender.props.disabled = false
              // 佣金金额(元)  禁止编辑 设置为0
            } else if (row[column.field] === '金额') {
              this.$set(row, 'fyongjinbl', 0)
              colFieldFyongjinjine.editRender.props.disabled = false
              colFieldFyongjinbl.editRender.props.disabled = true
            }
          }
          break
        //
        case 'fisryrq': // ICER版本（燃气或者燃油版）开始
          switch (row[column.field]) {
            case '无':
              fisscr.editRender.options = [
                { label: 'HPSCR', value: 'HPSCR' },
                { label: 'LPSCR', value: 'LPSCR' },
                { label: '否', value: '否' }
              ]
              fscrlowup.editRender.options = [
                { label: '低硫', value: '低硫' },
                { label: '高硫', value: '高硫' },
                { label: '否', value: '否' }
              ]

              fisegr.editRender.options = [
                { label: 'EcoEGR', value: 'EcoEGR' },
                { label: 'EGRBP', value: 'EGRBP' },
                { label: '否', value: '否' }
              ]
              fegrlowup.editRender.options = [
                { label: '低硫', value: '低硫' },
                { label: '高硫', value: '高硫' },
                { label: '否', value: '否' }
              ]
              break
            default:
              fisscr.editRender.options = [
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fisscr', '否')
              fscrlowup.editRender.options = [
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fscrlowup', '否')
              fisegr.editRender.options = [
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fisegr', '否')
              fegrlowup.editRender.options = [
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fegrlowup', '否')
              break
          }
          break
        case 'fisscr': // 是否含SCR
          switch (row[column.field]) {
            case '否':
              fscrlowup.editRender.options = [ // 含SCR低高硫
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fscrlowup', '否')

              fisryrq.editRender.options = [ // ICER版本（燃气或者燃油版）
                { label: '燃油', value: '燃油' },
                { label: '燃气', value: '燃气' },
                { label: '无', value: '无' }
              ]

              fisegr.editRender.options = [ // 是否含EGR
                // { label: '是', value: '是' }
                { label: 'EcoEGR', value: 'EcoEGR' },
                { label: 'EGRBP', value: 'EGRBP' },
                { label: '否', value: '否' }
              ]
              // this.$set(row, 'fisegr', '是')

              fegrlowup.editRender.options = [ // 含SCR低高硫
                // { label: '低硫', value: '低硫' },
                // { label: '高硫', value: '高硫' }
                { label: '低硫', value: '低硫' },
                { label: '高硫', value: '高硫' },
                { label: '否', value: '否' }
              ]
              // this.$set(row, 'fegrlowup', '')
              break
            default: // HPSCR  LPSCR
              fisryrq.editRender.options = [
                { label: '无', value: '无' }
              ]
              this.$set(row, 'fisryrq', '无')

              fscrlowup.editRender.options = [
                { label: '低硫', value: '低硫' },
                { label: '高硫', value: '高硫' }
              ]
              if (row.fscrlowup === '否') {
                this.$set(row, 'fscrlowup', '')
              }

              fisegr.editRender.options = [
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fisegr', '否')

              fegrlowup.editRender.options = [
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fegrlowup', '否')
              break
          }
          break

        case 'fscrlowup': // 含SCR低高硫
          switch (row[column.field]) {
            case '否':
              fisscr.editRender.options = [ // 是否含SCR
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fisscr', '否')

              fisryrq.editRender.options = [ // ICER版本（燃气或者燃油版）
                { label: '燃油', value: '燃油' },
                { label: '燃气', value: '燃气' },
                { label: '无', value: '无' }
              ]

              fisegr.editRender.options = [ // 是否含EGR
                // { label: '是', value: '是' }
                { label: 'EcoEGR', value: 'EcoEGR' },
                { label: 'EGRBP', value: 'EGRBP' },
                { label: '否', value: '否' }
              ]
              // this.$set(row, 'fisegr', '是')

              fegrlowup.editRender.options = [ // 含SCR低高硫
                { label: '低硫', value: '低硫' },
                { label: '高硫', value: '高硫' },
                { label: '否', value: '否' }
              ]
              // this.$set(row, 'fegrlowup', '')
              break
            default: // 低硫  高硫
              fisryrq.editRender.options = [
                { label: '无', value: '无' }
              ]
              this.$set(row, 'fisryrq', '无')

              fisscr.editRender.options = [
                { label: 'HPSCR', value: 'HPSCR' },
                { label: 'LPSCR', value: 'LPSCR' }
              ]
              if (row.fisscr === '否') {
                this.$set(row, 'fisscr', '')
              }

              fisegr.editRender.options = [
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fisegr', '否')

              fegrlowup.editRender.options = [
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fegrlowup', '否')
              break
          }
          break
        // -----------------------------------------------
        case 'fisegr': // 是否含EGR
          switch (row[column.field]) {
            case '否':
              fegrlowup.editRender.options = [ // 含EGR低高硫
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fegrlowup', '否')

              fisryrq.editRender.options = [ // ICER版本（燃气或者燃油版）
                { label: '燃油', value: '燃油' },
                { label: '燃气', value: '燃气' },
                { label: '无', value: '无' }
              ]
              this.$set(row, 'fisryrq', '')

              fisscr.editRender.options = [ // 是否含SCR
                { label: 'HPSCR', value: 'HPSCR' },
                { label: 'LPSCR', value: 'LPSCR' },
                { label: '否', value: '否' }
              ]
              // console.log(row.fisscr, ' row.fisscr')
              // this.$set(row, 'fisscr', '')

              fscrlowup.editRender.options = [ // 含SCR低高硫
                { label: '低硫', value: '低硫' },
                { label: '高硫', value: '高硫' },
                { label: '否', value: '否' }
              ]
              // this.$set(row, 'fscrlowup', '')
              break
            default: // EcoEGR  EGRBP
              fisryrq.editRender.options = [
                { label: '无', value: '无' }
              ]
              this.$set(row, 'fisryrq', '无')

              fisscr.editRender.options = [
                { label: '否', value: '否' }
              ]
              // console.log(row.fisscr, ' row.fisscr  111111')
              this.$set(row, 'fisscr', '否')

              fscrlowup.editRender.options = [
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fscrlowup', '否')

              fegrlowup.editRender.options = [
                { label: '低硫', value: '低硫' },
                { label: '高硫', value: '高硫' }
              ]
              if (row.fegrlowup === '否') {
                this.$set(row, 'fegrlowup', '')
              }
              break
          }
          break

          // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        case 'fegrlowup': // 含EGR低高硫
          switch (row[column.field]) {
            case '否':
              fisryrq.editRender.options = [ // ICER版本（燃气或者燃油版）
                { label: '燃油', value: '燃油' },
                { label: '燃气', value: '燃气' },
                { label: '无', value: '无' }
              ]
              this.$set(row, 'fisryrq', '')

              fisscr.editRender.options = [ // 是否含SCR
                { label: 'HPSCR', value: 'HPSCR' },
                { label: 'LPSCR', value: 'LPSCR' },
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fisscr', '')

              fscrlowup.editRender.options = [ // 含SCR低高硫
                { label: '低硫', value: '低硫' },
                { label: '高硫', value: '高硫' },
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fscrlowup', '')

              fisegr.editRender.options = [ // 是否含EGR
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fisegr', '否')

              break
            default: // 低硫  高硫

              fisegr.editRender.options = [
                { label: 'EcoEGR', value: 'EcoEGR' },
                { label: 'EGRBP', value: 'EGRBP' }
              ]
              // this.$set(row, 'fisegr', '')

              fisryrq.editRender.options = [
                { label: '无', value: '无' }
              ]
              this.$set(row, 'fisryrq', '无')

              fisscr.editRender.options = [
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fisscr', '否')

              fscrlowup.editRender.options = [
                { label: '否', value: '否' }
              ]
              this.$set(row, 'fscrlowup', '否')
              break
          }
          break
          // -------------燃气版结束---------------------
        case 'fisyaokongsys': // 是否借船厂遥控系统
          if (row[column.field] === '否') {
            this.$set(row, 'fisykstyunfei', 0)
            colFieldFisykstyunfei.editRender.props.disabled = true
          } else {
            colFieldFisykstyunfei.editRender.props.disabled = false
          }
          break
        default:
          break
      }
      // console.log({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex }, ' {row,rowIndex,$rowIndex,column,columnIndex,$columnIndex}')
    },
    // 字段
    async getvxetableBillConfig() {
      const res = await vxetableBillConfig(
        {
          FUnControl: -1,
          opername: this.opername,
          FRepKey,
          FRepPage: 1

        }
      )
      this.oriColumnData = res.Data
      const dataVxe = []
      // setTimeout(() => {
      if (res.Data.length > 0) {
        this.columnData.push({
          type: 'seq',
          width: 50,
          fixed: 'left'
        })
        // this.columnData.push({
        //   type: 'checkbox',
        //   width: 50,
        //   fixed: 'left'
        // })

        for (let i = 0; i < res.Data.length; i++) {
          // FRepType 202, 200 -- 文本， 131 --数值 ，135 -- 日期
          if (res.Data[i].fheaderfooter === 1) {
            // 表体字段
            if (res.Data[i].falign === 1) {
              this.columnData.push({
                field: res.Data[i].frepfld,
                title: res.Data[i].frepcap,

                headerAlign: 'left',
                align: 'right',

                width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                editRender: { name: 'input', attrs: { disabled: Boolean(res.Data[i].fisedit), placeholder: '' }}
              })
            } else if (res.Data[i].frepmeg === 1) {
              if (
                res.Data[i].frepfld === 'fisjiazhang' // 是否有加账

              ) { // 是否含SCR
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: { name: '$select', enabled: !res.Data[i].fisedit, options: [
                    { label: '是', value: '是' },
                    { label: '否', value: '否' }],
                  props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap },
                  placeholder: '请选择' }
                })
              }

              if (
                res.Data[i].frepfld === 'fisyaokongsys' // 是否借船厂遥控系统
              ) { // 是否含SCR
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: {
                    name: '$select',
                    enabled: !res.Data[i].fisedit,
                    options: [
                      { label: '是', value: '是' },
                      { label: '否', value: '否' }],
                    events: { change: this.changeVal },
                    props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap }}
                })
              }

              if (
                res.Data[i].frepfld === 'fisegr'
              ) { // 是否含SCR
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: {
                    name: '$select',
                    enabled: !res.Data[i].fisedit,
                    options: this.fisegrOptions,
                    events: { change: this.changeVal },
                    props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap }}
                })
              }

              if (res.Data[i].frepfld === 'fisscr' // 是否含SCR
              ) { // 是否含SCR
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: {
                    name: '$select',
                    enabled: !res.Data[i].fisedit,
                    options: [
                      { label: 'HPSCR', value: 'HPSCR' },
                      { label: 'LPSCR', value: 'LPSCR' },
                      { label: '否', value: '否' }
                    ],
                    events: { change: this.changeVal },
                    props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap }}
                })
              }

              if (res.Data[i].frepfld === 'fscrlowup' || // 含SCR低高硫
              res.Data[i].frepfld === 'fegrlowup' // 含SCR低高硫
              ) { // 是否含SCR
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: {
                    name: '$select',
                    enabled: !res.Data[i].fisedit,
                    options: [
                      { label: '低硫', value: '低硫' },
                      { label: '高硫', value: '高硫' },
                      { label: '否', value: '否' }
                    ],
                    events: { change: this.changeVal },
                    props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap }}
                })
              }

              if (res.Data[i].frepfld === 'fmpctriton') { // MPC/TRITON
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: { name: '$select', enabled: !res.Data[i].fisedit, options: [
                    { label: 'MPC', value: 'MPC' },
                    { label: 'TRITON', value: 'TRITON' }
                  ], props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap }, placeholder: '请选择' }
                })
              }

              if (res.Data[i].frepfld === 'fzhujiranliaos') { // 主机燃料硫含
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: { name: '$select', enabled: !res.Data[i].fisedit, options: [
                    { label: '0.1%', value: '0.1%' },
                    { label: '3.5%', value: '3.5%' }
                  ], props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap }, placeholder: '请选择' }
                })
              }

              // console.log(res.Data[i].frepfld, ' res.Data[i].frepfld')
              if (res.Data[i].frepfld === 'fisryrq') { // ICER版本（燃气或者燃油版）
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: {
                    name: '$select',
                    enabled: !res.Data[i].fisedit,
                    options: [
                      { label: '燃油', value: '燃油' },
                      { label: '燃气', value: '燃气' },
                      { label: '无', value: '无' }
                    ],
                    events: { change: this.changeVal },
                    props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap }}
                })
              }

              if (res.Data[i].frepfld === 'fchuanjishe') { // 船级社
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: { name: '$select', enabled: !res.Data[i].fisedit, options: [
                    { label: 'CCS', value: 'CCS' },
                    { label: 'ABS', value: 'ABS' },
                    { label: 'LR', value: 'LR' },
                    { label: 'BV', value: 'BV' },
                    { label: 'NK', value: 'NK' },
                    { label: 'DNV', value: 'DNV' },
                    { label: '无', value: '无' }
                  ], props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap }, placeholder: '请选择' }
                })
              }

              if (res.Data[i].frepfld === 'fgvuigpr') { // GVU/IGPR
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: { name: '$select', enabled: !res.Data[i].fisedit, options: [
                    { label: 'GVU', value: 'GVU' },
                    { label: 'IGRP', value: 'IGRP' },
                    { label: '无', value: '无' }
                  ], props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap }, placeholder: '请选择' }
                })
              }

              if (res.Data[i].frepfld === 'fisyongjinbl') { // 是否佣金比例  佣金
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: {
                    name: '$select',
                    enabled: !res.Data[i].fisedit,
                    options: this.fisyongjinblOptions,
                    events: { change: this.changeVal },
                    props: { value: '', placeholder: '请输入' + res.Data[i].frepcap }}
                })
              }

              if (res.Data[i].frepfld === 'fisjingneijingwai') { // 境内/境外佣金
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: {
                    name: '$select',
                    enabled: !res.Data[i].fisedit,
                    options: this.fisjingneijingwaiOptions,
                    events: { change: this.changeVal },
                    props: { value: this.fisjingneijingwaiVal, placeholder: '请输入' + res.Data[i].frepcap }}
                })
              }

              if (res.Data[i].frepfld === 'fzhibaoqi') { // 延长质保期
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: { name: '$select', enabled: !res.Data[i].fisedit, options: [
                    { label: '0月', value: '0月' },
                    { label: '1月', value: '1月' },
                    { label: '2月', value: '2月' },
                    { label: '3月', value: '3月' },
                    { label: '4月', value: '4月' },
                    { label: '5月', value: '5月' },
                    { label: '6月', value: '6月' },
                    { label: '7月', value: '7月' },
                    { label: '8月', value: '8月' },
                    { label: '9月', value: '9月' },
                    { label: '10月', value: '10月' },
                    { label: '11月', value: '11月' },
                    { label: '12月', value: '12月' }
                  ], props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap }, placeholder: '请选择' }
                })
              }
            } else {
              if (res.Data[i].frepmeg === 4) {
              // 日期 4
                console.log(res.Data[i].frepfld, ' res.Data[i].frepfld')
                this.columnData.push({
                  field: res.Data[i].frepfld,
                  title: res.Data[i].frepcap,
                  headerAlign: 'left',
                  align: 'right',
                  width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                  editRender: { attrs: { disabled: Boolean(res.Data[i].fisedit) }},
                  props: { type: 'float', placeholder: '请输入' + res.Data[i].frepcap },
                  slots: { edit: res.Data[i].frepfld + '_edit' }
                })
                this.fyjDisabled = Boolean(res.Data[i].fisedit)
              } else {
                console.log(res.Data[i], res.Data[i].frepfld, ' res.Data[i].frepfld ', res.Data[i].frepcap, res.Data[i].freptype)
                // fsxtaishu 生效台数
                // fsjpower    设计功率
                // fhtpower    合同功率
                // fyunbaof    运保费
                // fisykstyunfei   借遥控系统运费
                // fzlyhamount    专利费优惠金额
                // fmarketprice   市场价格
                // fyongjinbl    佣金比例
                // fyongjinjine  佣金金额(元)
                if (
                  res.Data[i].frepfld === 'fsjpower' || // 设计功率
                // res.Data[i].frepfld === 'fsxtaishu' || // 生效台数
                res.Data[i].frepfld === 'fyongjinjine' || // 佣金金额(元)
                res.Data[i].frepfld === 'fhtpower' || // 合同功率
                res.Data[i].frepfld === 'fyunbaof' || // 运保费
                res.Data[i].frepfld === 'fisykstyunfei' || // 借遥控系统运费
                res.Data[i].frepfld === 'fzlyhamount' || // 专利费优惠金额
                res.Data[i].frepfld === 'fmarketprice' // 市场价格

                ) {
                  this.columnData.push({
                    field: res.Data[i].frepfld,
                    title: res.Data[i].frepcap,
                    // showHeaderOverflow: true,
                    // showOverflow: true,
                    // resizable: true,
                    width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                    formatter({ cellValue }) {
                      return cellValue ? `${XEUtils.commafy(Number(cellValue), { digits: res.Data[i].fdecplaces })}` : 0
                    },
                    editRender: {
                      name: '$input',
                      attrs: { disabled: Boolean(res.Data[i].fisedit), placeholder: '' },
                      props: { type: 'number', min: 0, disabled: Boolean(res.Data[i].fisedit), controls: false, placeholder: '请输入数值' }
                    }
                  })
                } else if (
                  res.Data[i].frepfld === 'fyongjinbl' // 佣金比例
                ) {
                  this.columnData.push({
                    field: res.Data[i].frepfld,
                    title: res.Data[i].frepcap,
                    // showHeaderOverflow: true,
                    // showOverflow: true,
                    // resizable: true,
                    width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                    formatter({ cellValue }) {
                      // console.log(cellValue, ' cellValue 佣金比例')
                      let cellTemp = XEUtils.commafy(Number(cellValue), { digits: res.Data[i].fdecplaces })
                      cellTemp = Number(cellTemp) * 100
                      return cellValue ? `${cellTemp}%` : 0
                    },
                    editRender: {
                      name: '$input',
                      attrs: { disabled: Boolean(res.Data[i].fisedit), placeholder: '' },
                      props: { type: 'number', min: 0, max: 1, disabled: Boolean(res.Data[i].fisedit), controls: false, placeholder: '请输入数值' }
                    }
                  })
                } else {
                  this.columnData.push({
                    field: res.Data[i].frepfld,
                    title: res.Data[i].frepcap,
                    // showHeaderOverflow: true,
                    // showOverflow: true,
                    // resizable: true,
                    width: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0,
                    editRender: { name: 'input', attrs: { disabled: Boolean(res.Data[i].fisedit), placeholder: '' }}
                  })
                }
              }
            }
          } else {
            // 表头
            this.dialogThead.push(res.Data[i])
            // columnHeaderData
            this.columnHeaderData.push({
              field: res.Data[i].frepfld,
              title: res.Data[i].frepcap,
              // showHeaderOverflow: true,
              // showOverflow: true,
              // resizable: true,
              titleColon: true,
              titleWidth: res.Data[i].frepwid > 0 ? res.Data[i].frepwid : 0

            })

            // this.$set(this.formData, i, data[i])
            // this.formData.items = this.columnHeaderData
          }
        }
        // console.log(this.dialogThead, this.columnHeaderData)+
        //    for (const i in data) {
        //   this.$set(this.form, i, data[i])
        // }

        this.dialogThead.map(item => { dataVxe[item.frepfld] = '' })
        for (const i in dataVxe) {
          this.$set(this.formData, i, dataVxe[i])
        }

        // console.log(this.columnData, ' this.columnData')

        this.gridOptions.columns = this.columnData
      }
      // }, 1000)
    },
    handleNodeClick(data) {
      console.log(data)
    },
    async confirmSendMsg() {
      const selectMsgArr = this.$refs.selectTree.getCheckedKeys(true)
      this.dialogSendMsgModal = true
      try {
        const fcontent = this.formSendMsg.fcontent
        const fbillno = this.formData.fbillno
        if (selectMsgArr.length) {
          const fid = selectMsgArr.join(',')
          if (!fid) {
            this.$message({
              message: '手机号为空',
              type: 'error'
            })
            return
          }

          const res = await sendsms({
            opername: decodeURIComponent(this.globalDb.fname),
            fid,
            fcontent,
            fbillno
          })
          console.log(res, ' res')
          if (res.Error === 0) {
            this.mulSendMsgSelect = []
            this.formSendMsg.fcontent = ''
            this.dialogSendMsgModal = false
          }
        } else {
          this.$message({
            message: '未选中发送信息通知人员',
            type: 'error'
          })
          return
        }
      } catch (error) {
        this.dialogSendMsgModal = false
      }
    },
    async getBeijianTree() {
      try {
        this.sendMsgLoading = true
        const res = await beijianTree({
          opername: decodeURIComponent(this.globalDb.fname)
        })
        console.log(res, ' res')

        this.sendUsrList = res.Data
        this.sendMsgLoading = false
      } catch (error) {
        this.sendMsgLoading = false
        console.log(error)
      }
    },
    async getAdmin() {
      try {
        this.sendMsgLoading = true
        const res = await admin({
          db: this.globalDb.db,
          opername: this.loginname,
          keyword: this.keyword,
          username: this.loginname,
          limit: this.pagesize,
          page: this.currentPage
        })
        this.userList = res.result
      } catch (error) {
        console.log(error)
      }
    },
    // 保存
    async vxeSave() {
      const $grid = this.$refs.xGrid
      const { insertRecords, removeRecords, updateRecords } = $grid.getRecordset()
      const { tableData } = $grid.getTableData()
      console.log(insertRecords, removeRecords, updateRecords, 111111, this.formData)
      console.log(tableData, ' 333 tableData')
      if (insertRecords.length === 0 && updateRecords.length === 0 && removeRecords.length === 0) {
        VXETable.modal.message({ content: `新增 ${insertRecords.length} 条，更新 ${updateRecords.length} 条`, status: 'warning' })
        return
      }
      // 修改时 是否已审核
      if (updateRecords.length > 0) {
        const isFstatus = updateRecords.filter(it => Number(it.fstatus) === 1)
        if (isFstatus.length) {
          this.$message({
            message: '已审核，不能修改！',
            type: 'error'
          })
          return
        }
      }

      // const insertRecordsArr = []
      // insertRecords.map(it => {
      //   if (it.fmodel) {
      //     insertRecordsArr.push(it)
      //   }
      // })

      // const tableDataArr = []
      // tableData.map(it => {
      //   if (it.fmodel) {
      //     tableDataArr.push(it)
      //   }
      // })

      try {
        const res = await billGenAdd({
          FRepKey,
          opername: this.opername,
          insertRecords,
          // insertRecords: insertRecordsArr,
          updateRecords,
          removeRecords,
          // tableData: tableDataArr,
          tableData,
          formdata: this.formData
        })
        if (res.Error === 0) {
          this.$message({
            message: res.Message,
            type: 'success'
          })
          this.$router.push('/baojia/markethx')
        } else {
          this.$message({
            message: res.Message,
            type: 'error'
          })
        }

        // this.getvxetableGenList()
      } catch (error) {
        console.log(error)
      }

      // VXETable.modal.message({ content: `新增 ${insertRecords.length} 条，更新 ${updateRecords.length} 条`, status: 'success' })
    },
    // 内容列表
    async getvxetableGenList() {
      const param = {
        opername: decodeURIComponent(this.globalDb.fname),
        FRepKey,
        keyword: this.keyword,
        isHebing: this.isHebing,
        fstatus: this.fstatus,
        page: this.tablePage.currentPage,
        pageSize: this.tablePage.pageSize
      }
      const res = await XsbList(param)
      setTimeout(() => {
        this.tablePage.total = res.total
        // this.gridOptions.data = res.Data
        // res.Data
      }, 0)
    },
    // 编辑内容设置
    async getBillGenEdit() {
      const param = { FRepKey, fid, opername: this.opername }
      const res = await billGenEdit(param)
      setTimeout(() => {
        const $grid = this.$refs.xGrid
        for (let i = 0; i < res.Data.length; i++) {
          $grid.insert(res.Data[i], -1)
        }
        // 初始值判断
        const { tableData } = $grid.getTableData()
        const colFieldFyongjinjine = $grid.getColumnByField('fyongjinjine')
        const colFieldFyongjinbl = $grid.getColumnByField('fyongjinbl')
        // fisyaokongsys 是否借船厂遥控系统
        // fisykstyunfei // 借遥控系统运费
        const colFieldFisykstyunfei = $grid.getColumnByField('fisykstyunfei')
        tableData.map(row => {
          console.log(row, ' row 2222')
          // 佣金
          if (row.fisyongjinbl === '无') {
            colFieldFyongjinjine.editRender.props.disabled = true
            colFieldFyongjinbl.editRender.props.disabled = true
          } else if (row.fisyongjinbl === '比例') {
            colFieldFyongjinjine.editRender.props.disabled = true
            colFieldFyongjinbl.editRender.props.disabled = false
          } else if (row.fisyongjinbl === '金额') {
            colFieldFyongjinjine.editRender.props.disabled = false
            colFieldFyongjinbl.editRender.props.disabled = true
          }

          if (row.fisyaokongsys === '否') {
            this.$set(row, 'fisykstyunfei', 0)
            colFieldFisykstyunfei.editRender.props.disabled = true
          }
          //
        })

        this.$set(this.formData, 'fbillno', res.Data[0].fbillno)
        this.$set(this.formData, 'fchuanmin', res.Data[0].fchuanmin)
        this.$set(this.formData, 'fchuanhao', res.Data[0].fchuanhao)
        this.$set(this.formData, 'fmodel', res.Data[0].fmodel)
        this.$set(this.formData, 'fprodectno', res.Data[0].fprodectno)
        this.$set(this.formData, 'fcustomer', res.Data[0].fcustomer)
      }, 0)
    },
    // 按钮点击
    async toolbarButtonClickEvent({ code }) {
      console.log(code, 'code toolbarButtonClickEvent')
      const $grid = this.$refs.xGrid
      switch (code) {
        case 'dataSettings': // 单据设置
          this.settings()
          break
        case 'sqlSettings': // 显示SQL语句
          this.dialogSQL()
          break
        case 'myAdd': // 新增
          $grid.insertAt(-1, -1)
          break
        case 'myDelete':
          // 删除当前行
          $grid.remove($grid.getCurrentRecord())
          break
        // 保存
        case 'save':
          // this.vxeSave()
          console.log(222222222222, 'save')
          break
        case 'mySend': // 发送信息
          this.dialogSendMsgModal = true
          await this.getBeijianTree()
          break
        case 'myFresh': // 刷新
          window.location.reload()
          break
        case 'myBack': // 返回
          this.$router.push('/baojia/markethx')
          break
      }
    },
    checkColumnMethod({ column }) {
      if (['nickname', 'role'].includes(column.property)) {
        return false
      }
      return true
    }

  }
}

</script>
<style lang="scss" scoped>
.config-dialog ::v-deep .el-dialog {
  width: 70%;
}
.config-dialog ::v-deep .el-dialog__body {
  padding: 0px 20px;
}
.cb-set-modal ::v-deep .el-dialog__body {
  padding: 0 20px;
  max-height: 750px!important;
  overflow: scroll;
}
.cb-set-modal ::v-deep .single-select-table thead .el-table-column--selection .cell {
  display: none;
}
.import-set-modal {
  .search-grid {
    margin-bottom: 10px;
  }
}
.import-set-modal ::v-deep .el-dialog__body {
  padding: 0 20px;
 }
</style>
